<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.4.5/angular.min.js"></script>
<title>代理商</title>
</head>

<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">

		<style>
.main_div {
	min-width: 1000px;
	min-height: 60px
}

.force-overflow1-1 {
	border: none
}

.buttonPic>span {
	color: #FFFFFF;
	font-size: 36px
}
</style>
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>审核超市信息</span>
					</div>
					<form class="form-inline"
						style="margin-top: 30px;margin-left: 20px">
						<div class="form-group offset-col-xs-3">
							<label for="orderCode"> 超市名称:</label> <input type="text"
							class="form-control" id="superName"
								placeholder="">
						</div>
						<button type="button" onclick="selectinfo()" class="btn btn-primary">立即查询</button>
					</form>
				</div>
				<div class="force-overflow1-1">
					<table class="table table-condensed table-bordered table-hover" id="showtable"
						show-filter="true" style="text-align: center">
						<tr style="background-color: #59c7d2">
							<th style="text-align: center">超市名称</th>
							<th style="text-align: center">电话</th>
							<th style="text-align: center">起送费用</th>
							<th style="text-align: center">满免</th>
							<th style="text-align: center">配送费</th>
							<th style="text-align: center">配送人</th>
							<th style="text-align: center">配送电话</th>
							<th style="text-align: center">配送时间</th>
							<th style="text-align: center">售后服务</th>
							<th style="text-align: center">通过审核</th>
							<th style="text-align: center">不通过审核</th>
						</tr>
					</table>
					<div class="pageChange">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button class="btn btn-primary" onclick="searchPage()">搜索</button>
					</div>
					<input style="display:none" value="7" id="pageCount"
							name="pageCount" />
				</div>
			</div>
		</section>

	</div>
	<script>
	$(function() {
			selectinfo()
		})
	
		
	
		function selectinfo() {
		//alert(localStorage.getItem("agentid"))
			var pageNum = $("#pageNum").html();
			var pageCount = $("#pageCount").val();
			var superName = $("#superName").val();

			if (superName == "") {
				superName = null;
			}		
			$.post(urls+"agentAction/getSuperMarketSetinfo",
				{
					superName:superName,
					pageNum : pageNum,
					pageCount : pageCount,
					agentId:localStorage.getItem("agentid")
				},
				function(data) {
					//console.log(data)
					if (data) {
						var totalpage = data.totalpage;
						var orderlist = data.setlist;
						var table = $("#showtable");
						$("tr").remove(".addtr");
						for (var i = 0; i < orderlist.length; i++) {
							var append = "<tr class='addtr'><td>" + orderlist[i].superName + "</td>" +
								"<td >"+ orderlist[i].sendPhone + "</td>" +
								"<td>" + orderlist[i].upSendMoney + "</td>" +
								"<td>" + orderlist[i].freeSendMoney + "</td>" +
								"<td>" + orderlist[i].sendMoney + "</td>" +
								"<td>" + orderlist[i].sendPeople + "</td>" +
								"<td>" + orderlist[i].sendPhone + "</td>" +
								"<td>" + orderlist[i].sendTime + "</td>" +
								"<td>" + orderlist[i].afterService + "</td>" +
								"<td><input onclick='detailinfo(\"" + orderlist[i].supermarketId +"|$"+"2\")' type='button' class='btn btn-primary' value='通过审核' /></td>" +
								"<td><input onclick='detailinfo(\"" + orderlist[i].supermarketId +"|$"+"3\")' type='button' class='btn btn-primary' value='不通过审核' /></td></tr>";
							table.append(append);
						}
						$("#totalpage").html(totalpage);
					}
				}
				, "json"
			)
		}
			function detailinfo(e) { 
			var attr=e.split("|$")
			$.post(urls+"agentAction/agreeOrNotSuperMarketSet",
			{
			  status:attr[1],
			  supermarketId:attr[0]
			},
			function(res){
			console.log(res)
			if(res){
			 alert("操作成功");
			 selectinfo()
			}else{
			alert("操作失败")
			}			
			})			
			}
			
	</script>
</body>
</html>
